

// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"

#ifdef __BORLANDC__
    #pragma hdrstop
#endif

// for all others, include the necessary headers (this file is usually all you
// need because it includes almost all "standard" wxWidgets headers
#ifndef WX_PRECOMP
    #include "wx/wx.h"
#endif


#include "wx/app.h"
#include "wx/grid.h"
#include "wx/treectrl.h"
#include "wx/spinctrl.h"
#include "wx/artprov.h"
#include "wx/clipbrd.h"
#include "wx/image.h"
#include "wx/colordlg.h"
#include "wx/wxhtml.h"
#include "wx/imaglist.h"
#include "wx/dataobj.h"
#include "wx/dcclient.h"
#include "wx/bmpbuttn.h"
#include "wx/menu.h"
#include "wx/toolbar.h"
#include "wx/statusbr.h"
#include "wx/msgdlg.h"
#include "wx/textdlg.h"

#include "wx/aui/aui.h"

#include "eveMapEditor.h"
#include "MapEditorPanel.h"


class MyApp : public wxApp
{
public:
   
    virtual bool OnInit();
};
enum
{
	
	wxID_NB_CTRL = 10,
	wxID_MAPSCENE = 11,
	
};
// Define a new frame type: this is going to be our main frame
class MyFrame : public wxFrame
{
public:
    // ctor(s)
    MyFrame(const wxString& title);
	~MyFrame();

    // event handlers (these functions should _not_ be virtual)
    void OnQuit(wxCommandEvent& event);
    void OnAbout(wxCommandEvent& event);
	void OnIdle( wxIdleEvent& event );
	//void OnSize(wxSizeEvent& evt);
	//void OnMaxSize(wxMaximizeEvent& evt);

private:
	//void updatePanelSize(const wxSize& size);

private:
	MapEditorPanel* m_pMapEditorPanel;
  
    DECLARE_EVENT_TABLE()
};


BEGIN_EVENT_TABLE(MyFrame, wxFrame)
   EVT_MENU(wxID_ABOUT, MyFrame::OnAbout)
   EVT_MENU(wxID_EXIT,  MyFrame::OnQuit)
  // EVT_PAINT(MyFrame::OnIdle)
  // EVT_SIZE(MyFrame::OnSize)
  // EVT_MAXIMIZE(MyFrame::OnMaxSize)
END_EVENT_TABLE()

IMPLEMENT_APP(MyApp)

//-----------------------------------------------------------------------------
bool MyApp::OnInit()
{
   
    MyFrame *frame = new MyFrame(_("mapeditor"));
    frame->Show();

    return true;
}


// frame constructor
MyFrame::MyFrame(const wxString& title)
       : wxFrame((wxFrame *)NULL, wxID_ANY, title)
	   , m_pMapEditorPanel(NULL)
{
    // create a menu bar
    wxMenu *menuFile = new wxMenu;

    menuFile->Append(wxID_ABOUT);
    menuFile->Append(wxID_EXIT);

    // now append the freshly created menu to the menu bar...
    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append(menuFile, _("&File"));

    // ... and attach this menu bar to the frame
    SetMenuBar(menuBar);
	int height = menuBar->GetSize().GetHeight();

	this->SetSize(1024,768);

	//wxPanel* panel = new wxPanel(this,wxID_MAPSCENE,0,height,700,750);
	m_pMapEditorPanel = new MapEditorPanel(this,wxID_MAPSCENE,0,height,700,750);

	//wxBoxSizer *topsizer = new wxBoxSizer( wxHORIZONTAL );
	//topsizer->Add( m_pMapEditorPanel, 1, wxEXPAND );
	//panel->SetSizer(topsizer);

	wxAuiNotebook* ctrl = new wxAuiNotebook(this, wxID_NB_CTRL,
                                    wxPoint(700,height),
                                    wxSize(324,750),wxAUI_NB_DEFAULT_STYLE | wxAUI_NB_TAB_EXTERNAL_MOVE | wxNO_BORDER);

 
	//wxPanel* 
   ctrl->AddPage(new wxPanel( ctrl, wxID_ANY ), wxT("wxAUI") , true);
   ctrl->AddPage(new wxTextCtrl( ctrl, wxID_ANY, wxT("Some text"),
                wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER), wxT("wxAUI1") , true);
   ctrl->AddPage(new wxTextCtrl( ctrl, wxID_ANY, wxT("Some text : test2"),
                wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxNO_BORDER), wxT("test2") , true);

   wxBoxSizer *topsizer = new wxBoxSizer( wxHORIZONTAL );
   topsizer->Add( m_pMapEditorPanel, 1, wxEXPAND | wxALL);
   topsizer->Add( ctrl, 0, wxEXPAND );
  
   topsizer->SetItemMinSize(ctrl,324,GetSize().y);
   topsizer->SetItemMinSize(m_pMapEditorPanel,GetSize().x-324,GetSize().y);
   SetAutoLayout( true );
   SetSizer(topsizer);
   topsizer->SetSizeHints( this );
	
}

MyFrame::~MyFrame()
{

}
// event handlers

void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    // true is to force the frame to close
    Close(true);

}

void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
 
}




//void MyFrame::OnSize(wxSizeEvent& event)
//{
//	this->updatePanelSize(event.GetSize());
//    event.Skip();
//}
